<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加市代理</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<script src="__PUBLIC__/static/js/area/area2.js" ></script>
	</head>

	<body>
		<form class="layui-form update_form" >
			<div class="layui-form-item">
				<label class="layui-form-label">选择省份</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select lay-filter="s_province" id="s_province" name="province"></select>
				</div>
				<div id="dc" class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select  lay-filter="s_city" id="s_city" name="city">
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"></label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="addres" required lay-verify="required" placeholder="详细地址" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">选择省代</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="ch_province" id="ch_province">
						{volist name="province" id="vo"}
							<option value="{$vo.id}">{$vo.user_name}</option>
						{/volist}
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手机号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" id="mobile" name="mobile" required lay-verify="required" placeholder="手机号" autocomplete="off" class="layui-input"> (作为登录账号)
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">姓名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_name" required lay-verify="required" placeholder="姓名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">登录密码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="password" required lay-verify="required" placeholder="登录密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label">操作密码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="operation_pwd" required lay-verify="required" placeholder="操作密码" autocomplete="off" class="layui-input">
				</div>
			</div>-->
			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="1" title="正常" checked>
					<input type="radio" name="status" value="2" title="冻结">
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit   lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>

			layui.use('form', function() {
				var form = layui.form;
				form.on('select(s_province)', function(data){
					change(1)
				});
				form.on('select(s_city)', function(data){
					alert(32);
				});
				form.on('submit(demo1)', function(data){
					var s=$("#s_province").val();
					var city = $("#s_city").val();
					if(s=='0'){
						layer.msg("请选择省份");
						return false;
					}
					if(city=='0'){
						layer.msg("请选择地级市");
						return false;
					}
					add_account();
				    return false;
				});
			});
			_init_area();
			var Gid = document.getElementById;
				//监听提交
			
			//提交表单
			function add_account() {
				var phone = $("#mobile").val();
				var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
				if(!reg.test(phone)) {
					layer.msg('手机号码格式不正确');
					onoff = true;
					return;
				}
				$.ajax({
					type: "post",
					url: "{:url('accounts/add_agency2')}",
					data: $('.layui-form').serialize(), //表单数据
					success: function(data) {
						if(data.code == 200) {
							layer.msg('添加成功', {
								icon: 1,
								time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								parent.layer.close(index);
							});
						} else {
							layer.msg(data.msg); //保存成功提示
						}
					},
					error: function(data) {
						var a = data;
					}
				});

			}
		</script>
	</body>

</html>